package com.study.webapp.socket.bio;

import java.net.ServerSocket;
import java.net.Socket;

public class TimeServer {


    public static void main(String[] args) throws Exception {
        int port = 8080;
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(port);
            System.out.println("时间服务开始端口："+port);
            Socket socket = null;
            TimeServerHandlerExecutorPool executorPool = new TimeServerHandlerExecutorPool(10,10000);
            while (true) {
                socket = serverSocket.accept();
                executorPool.execute(new TimeServerHandler(socket));
//                new Thread(new TimeServerHandler(socket)).start();
            }
        } finally {
            if (serverSocket != null) {
                serverSocket.close();
                System.out.println("服务关闭");
                serverSocket = null;
            }
        }


    }
}
